<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of Select
 *
 * @author chaporgin_a
 */
class VA_Form_ViewHelper_XHTML_Select extends VA_Form_ViewHelper_XHTML_WithChoice {
  public function wrap() {
    $return = '';
    foreach($this->getElement()->getOptions() as $value => $title) {
      $line = '';
      $selected = '';
      if( in_array($value, $this->getElement()->getValue()))
        $selected = 'selected="selected"';
      $line .= sprintf('<option value="%s" %s >%s</option>'
              , $value
              , $selected
              , $title
              ) . "\n";
      $return .= $line;
    }
    $name = $this->getElement()->getHTMLTagAttribute('name');
    $return = sprintf('<select %s %s %s %s %s>%s</select>'
            , $this->getElement()->getSelectionType()
            , $this->getElement()->getHTMLTagAttribute('style')
            , $this->getElement()->getHTMLTagAttribute('id')
            , $this->getElement()->getHTMLTagAttribute('class')
            , $name
            , $return);
    return $return;
  }
}

